#include "uart.h"

#include <stdio.h>

#include "cmsis_os2.h"
#include "wifiiot_gpio.h"
#include "wifiiot_gpio_ex.h"

#include "wifiiot_uart.h"

void uart2_init(void)
{
    uint8_t ret = 0;
    WifiIotUartAttribute uart2_init_struct;
    GpioInit();
    IoSetFunc(WIFI_IOT_IO_NAME_GPIO_11, WIFI_IOT_IO_FUNC_GPIO_11_UART2_TXD);
    IoSetFunc(WIFI_IOT_IO_NAME_GPIO_12, WIFI_IOT_IO_FUNC_GPIO_12_UART2_RXD);
    uart2_init_struct.baudRate = 115200;
    uart2_init_struct.dataBits = 8;
    uart2_init_struct.pad      = 0;
    uart2_init_struct.parity   = WIFI_IOT_UART_PARITY_NONE;
    uart2_init_struct.stopBits = 1;

    ret = UartInit(WIFI_IOT_UART_IDX_2, &uart2_init_struct, NULL);
    if(ret != 0)
    {
        printf("uart2 init fail\r\n"); 
    }
}